import { Info } from '@/appUtils/appData/lanhuTypes'
import { IFileItem } from '@/appUtils/fs'
import { ElMessageBox } from 'element-plus'
import { h } from 'vue'
import MessageBoxReplaceCom from './MessageBoxReplaceCom.vue'

export const MessageBoxReplace = (source: Info | IFileItem, target: string) => {
    return new Promise<boolean>(async (res) => {
        const msgBox = await ElMessageBox({
            title: '提示',
            showCancelButton: true,
            cancelButtonText: '取消',
            confirmButtonText: '确定',
            message: () => {
                return h(MessageBoxReplaceCom, {
                    source,
                    target,
                })
            },
        }).catch(() => null)
        if (!msgBox) {
            res(false)
            return
        }
        res(true)
    })
}
